const express = require('express');
const bodyParser = require('body-parser');
const app = express();

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.all('*', (req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET,POST');
  res.header('Access-Control-Allow-Headers', '*');
  next();
});

app.post('/submit', (req, res) => {
  const body = req.body;
  console.log(body);

  res.send({
    code: 0,
    msg: 'ok',
    data: req.body
  });
});

app.listen(8001, () => console.log('Server start on 8001.'));
